#include "../include/config.h"

int readConfig(const char *filename, HashTable *ht){
    FILE *fp = fopen(filename,"rw");

    if(fp == NULL){
        printf("open file %s error.\n",filename);
        return -1;
    }

    char buff[128] = {0};
    while(fgets(buff,sizeof(buff),fp) != NULL){
        char *strs[3] = {0};
        int cnt = 0;
        splitString(buff,"=",strs,3,&cnt);
        char *value = (char *)calloc(1,sizeof(strs[1] + 1));
        strcpy(value,strs[1]);
        insert(ht,strs[0],value);
        freeStrs(strs,cnt);
    }
    fclose(fp);
    return 0;
}
